<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>onmouseover()和onmouseout()事件</title>
    <style type="text/css">
        #box{
            width: 200px;
            height: 200px;
            background-color: red;
        }
    </style>
</head>
<body>
    <div id="box"></div>
    <script type="text/javascript">
        //  1.找开关  2.摁一下   3.灯亮了
        // 1.找到触发的事件对象
        // 2.鼠标滑过事件
        var oDiv = document.getElementById('box');
        oDiv.onmouseover = function(){
            // 3.事件处理程序
            this.style.backgroundColor = 'green';
        }

        // 2.鼠标移开事件
        oDiv.onmouseout = function(){
            // 3.事件处理
            this.style.backgroundColor = 'red';
        }
    </script>

</body>
</html>